<template>
  <div class="container">
    <div>
      <a-space>
        <a-button type="primary" @click="addEntity">
          <template #icon><icon-plus-circle /></template>同步
        </a-button>
        <a-button type="primary" @click="tongBuEntity">
          <template #icon><icon-plus-circle /></template>同步日志
        </a-button>
      </a-space>
    </div>
    <a-table :bordered="{cell:true}" :pagination="false" stripe :data="state.entityObj">
      <template #columns>
        <a-table-column title="销售订单号" data-index="xsdd"></a-table-column>
        <a-table-column title="客户名称" data-index="name"></a-table-column>
        <a-table-column title="日期" data-index="xsddrq"></a-table-column>
        <a-table-column title="单据类型" data-index="lx"></a-table-column>
        <a-table-column title="操作" width="250">
          <template #cell="{ record }">
            <a-space>
              <a-button type="primary" size="small" @click="viewEntity(record.id)"><template #icon><icon-eye /></template>查看</a-button>
              <a-button type="primary" size="small" status="warning" @click="createTaskTz(record.id)"><template #icon><icon-eye /></template>下推生成任务通知单</a-button>
            </a-space>
          </template>
        </a-table-column>
      </template>
    </a-table>
    <a-drawer title="同步日志" v-model:visible="state.tongbuVisible" :footer="false" width="1200px">
      <TongBuLog v-if="state.tongbuVisible" v-model="state.tongbuVisible" :entityId="state.popupEntityId"></TongBuLog>
    </a-drawer>
    <a-drawer title="销售订单详情" v-model:visible="state.viewEntityVisible" :footer="false" width="1200px">
      <XSDDView v-if="state.viewEntityVisible" v-model="state.viewEntityVisible" :entityId="state.popupEntityId"></XSDDView>
    </a-drawer>
    <a-modal title="销售订单转生产任务通知单" v-model:visible="state.taskTzVisible" :footer="false" width="1380px">
      <TasktzDetail v-if="state.taskTzVisible" v-model="state.taskTzVisible" :entityId="state.popupEntityId"></TasktzDetail>
    </a-modal>

    <ul>
      <li>
        同步日志可查看，最近同步的日志，方便定位
      </li>
      <li>
        销售订单可生成生产任务通知单，可在生产任务通知单里添加，根据选择销售订单生成，也可以在销售订单下推生成，可二选1。
      </li>
      <li>
        销售订单U9定时同步抓取，可支持手工同步最好。下面是U9的销售订单截图
      </li>
      <li>
        <img class="carousel-image" :src="XSDDImg"  alt=""/>
      </li>
    </ul>
  </div>
</template>

<script lang="ts" setup>
import { Message } from '@arco-design/web-vue'
import {reactive, ref, onMounted, onUnmounted, defineAsyncComponent} from "vue";
import { useRouter } from "vue-router";
import XSDDImg from '@/assets/images/xsdd.png'
const router = useRouter();
const XSDDView = defineAsyncComponent(() => import('@/views/product/xsdd/xsddView.vue'));
const TongBuLog = defineAsyncComponent(() => import('@/views/product/xsdd/tongbuLog.vue'));
const TasktzDetail = defineAsyncComponent(() => import('@/views/product/tasktz/tasktzDetail.vue'));

const state = reactive({
  entityObj: [],
  tongbuVisible : false,
  viewEntityVisible:false,
  taskTzVisible:false,
})
const loadList = ()=>{
  state.entityObj = [
    {id : 1, xsdd : 'S2025030007', name:'远景能源', lx:'来料销售', xsddrq:'2025-03-08'},
    {id : 2, xsdd : 'S2025010008', name:'远景能源', lx:'普通销售', xsddrq:'2025-03-12'},
    {id : 2, xsdd : 'S2025030010', name:'远景能源', lx:'来料销售', xsddrq:'2025-03-15'},
    {id : 3, xsdd : 'S2025010010', name:'远景能源', lx:'普通销售', xsddrq:'2025-03-16'},
  ]
}
const addEntity = ()=>{
  Message.success("同步了0条数据")
}
const tongBuEntity = ()=>{
  state.tongbuVisible=true
}
const viewEntity = (id)=>{
  state.viewEntityVisible = true
}
const createTaskTz = (id)=>{
  state.taskTzVisible = true
}
onMounted(()=>{
  loadList();
})
onUnmounted(()=>{
})
</script>

<style scoped lang="less">
ul{
  color: #f60000; font-weight: bold;font-size: 16px;
  li{
    padding : 10px;
  }
}
</style>
